from parameterized_testcase import parameterize

import my_module

# Define your "testcase" without subclassing from `unittest.TestCase`.
class MyTest:
    def setUp(self):
        # Here's where the class uses the parameters provided by
        # `parameterize()`.
        self.connection = my_module.open(
            type(self).backend)

    def test_something(self):
        self.assertTrue(...)

# Each key in `params` is a name of a parameterization. Each value in
# `params` is a dict defining attributes to add to the generated
# `TestCase` subclasses. In this case, each generated subclass will
# have an attribute named "backend".
params = {
    'sqlite': { 'backend': 'sqlite' }
    'postgres': { 'backend': 'postgres' },
}

# This actually generates the `unittest.TestCase` subclasses. The
# generated classes will be named "MyTest_<param-name>" where
# `<param-name>` comes from the keys in the params argument.
cases = list(
    parameterize(
        cases=[MyTest],
        params=params))
